import static org.junit.Assert.*;

import org.junit.Test;

/**
 * The Class VendingMachineItemTest; used to test the VendingMachineItem class.
 * 
 * @author Odessa
 */
public class VendingMachineItemTest
{

	/**
	 * Test method for
	 * {@link VendingMachineItem#VendingMachineItem(java.lang.String, double)}.
	 * Tests the constructor when the price >= zero.
	 */
	@Test
	public void testVendingMachineItem_PriceAboveZero()
	{
		VendingMachineItem coke = new VendingMachineItem("coke", 1.50);
		assertEquals("coke", coke.getName());
		assertEquals(1.50, coke.getPrice(), 0.001);
	}



	/**
	 * Test method for
	 * {@link VendingMachineItem#VendingMachineItem(java.lang.String, double)}.
	 * Tests the constructor when the price < zero.
	 */
	@Test(expected = VendingMachineException.class)
	public void testVendingMachineItem_PriceBelowZero()
	{
		VendingMachineItem coke = new VendingMachineItem("coke", -1.50);
	}



	/**
	 * Test method for
	 * {@link VendingMachineItem#VendingMachineItem(java.lang.String, double)}.
	 * Tests the constructor when the name is an empty string.
	 */
	@Test(expected = VendingMachineException.class)
	public void testVendingMachineItem_NameEmpty()
	{
		VendingMachineItem coke = new VendingMachineItem("", 1.50);
	}



	/**
	 * Test method for
	 * {@link VendingMachineItem#VendingMachineItem(java.lang.String, double)}.
	 * Tests the constructor when the name is null.
	 */
	@Test(expected = VendingMachineException.class)
	public void testVendingMachineItem_NameNull()
	{
		VendingMachineItem coke = new VendingMachineItem(null, 1.50);	
	}



	/**
	 * Test method for {@link VendingMachineItem#getName()}.
	 */
	@Test
	public void testGetName()
	{
		VendingMachineItem kitkat = new VendingMachineItem("kitkat", 1.00);
		VendingMachineItem doritos = new VendingMachineItem("doritos", 1.25);

		assertEquals("kitkat", kitkat.getName());
		assertEquals("doritos", doritos.getName());
	}



	/**
	 * Test method for {@link VendingMachineItem#getPrice()}.
	 */
	@Test
	public void testGetPrice()
	{
		VendingMachineItem kitkat = new VendingMachineItem("kitkat", 1.00);
		VendingMachineItem doritos = new VendingMachineItem("doritos", 1.25);

		assertEquals(1, kitkat.getPrice(), 0.001);
		assertEquals(1.25, doritos.getPrice(), 0.001);
	}

}
